package com.example.sinteractactivity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class Main3Activity extends AppCompatActivity {

    private TextView text3;
    private EditText edit3;
    private Button but3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);

        text3 = (TextView)findViewById(R.id.text3);
        edit3 = (EditText)findViewById(R.id.edit3);
        but3 = (Button)findViewById(R.id.but3);

        Intent intent = getIntent();
        text3.append("小张"+":"+intent.getStringExtra("msg"));
        but3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent2 = new Intent(Main3Activity.this,MainActivity.class);
                intent2.putExtra("msg2",edit3.getText().toString());
                setResult(RESULT_OK,intent2);
                finish();
            }
        });

    }
}
